<?php
  mysql_connect("localhost", "root", "password" ) or die( mysql_error());
  
  $q = "
    select 
      concat( p.description, '@', pr.price ) as product_name
    from
      overall_pos_db.product p
     ,overall_pos_db.product_rqcp pr
     ,overall_pos_db.product_category pc
     ,overall_pos_db.product_product_category ppc
    where
        p.product_id = pr.product_id
    and pc.product_category_id = ppc.product_category_id
    and ppc.product_id = p.product_id
    and pc.name = 'ALCLHOL'
    and p.description like '" . $_REQUEST['starts_with'] . "%'
    order by p.description asc
    limit 5;
  ";

  $r = mysql_query($q) or die( mysql_error());
  $n = mysql_numrows($r);

  for( $i = 0; $i < $n; $i++ ) {
    $e=mysql_fetch_assoc($r);
    $o[] = $e;
  }

  print(json_encode($o));
  mysql_close();
?>
